#include<bits/stdc++.h>
using namespace std;
struct car{
    int d,v;
    double a;
    double ff;
    int need_least;
}c[10001];
int n,m,l;
int check[10001];
bool need[10001];
double V;
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    int t;
    cin>>t;
    while(t--){
        int sum=0;
        cin>>n>>m>>l>>V;
        for(int i=1;i<=n;i++){
            cin>>c[i].d>>c[i].v>>c[i].a;
            c[i].need_least=-1;
        }
        for(int i=1;i<=m;i++)
            cin>>check[i];

        sort(check+1,check+1+m);
        for(int i=1;i<=n;i++){
            double f=(c[i].a==0.0 ? 0:(double)(V*V-c[i].v*c[i].v)/(double)(2*c[i].a));
            c[i].ff=(c[i].d+f==c[i].d ? 0 : c[i].d+f);
            //cout<<c[i].ff<<endl;

            for(int j=1;j<=m-1;j++){
                if(c[i].a==0&&c[i].v<=V)
                    break;
                else if(c[i].a==0&&c[i].v>V){
                    bool f=false;
                    sum++;
                    for(int k=1;k<=m;k++){
                        if(check[k]>=c[i].d)
                        {
                            c[i].need_least=check[k];
                            f=true;
                            break;
                        }
                    }
                    if(f)break;
                }
                else if(c[i].d>=check[j]&&c[i].ff<=check[j+1]&&c[i].a<0)
                    if(c[i].ff<=check[j+1]-check[j])
                        break;
                    else {
                        c[i].need_least=check[j+1];
                        sum++;
                        break;
                    }
                else if(c[i].a>0&&check[j]>f)
                {
                    c[i].need_least=check[j+1];
                    sum++;
                    break;
                }
            }
        }
        int ans=0;
        for(int i=1;i<=n;i++){
            if(c[i].need_least!=-1){
                need[c[i].need_least]=true;
            }
        }
        for(int i=1;i<=check[m];i++)
            if(need[i])
                ans++;

        cout<<sum<<" "<<ans<<"\n";
    }
    fclose(stdin);
    fclose(stdout);
    return 0;
}
